import {request} from '@/utils/http';

const LOGIN = '/login';
const WXLOGIN = '/api/wechat/applet/user/login';
const GETUSERINFO = '/api/wechat/applet/user';
const UPDATEUSERINFOURL = '/api/wechat/applet/user';
const LOGIN_OUT = '/logout';
const REFRESH_TOKEN = '/refresh/token';

/**
 * 登录
 * @param params
 */
export function login(params: LoginParams) {
    return request.Post<LoginModel>(LOGIN, params);
}

/**
 * 微信登录
 * @param params
 */
export function wxLogin(params: WxLoginParams) {
    return request.Post<LoginModel>(WXLOGIN, params);
}

/**
 * 获取用户信息
 * @param params
 */
export function getUserInfo() {
    return request.Get(GETUSERINFO);
}

/**
 * 修改用户信息
 * @param params
 * @param params2
 */
export function updateUserInfo(params: UpdateUserInfoParmas, params2: any) {
    return request.Put<UpdateUserInfoModel>(UPDATEUSERINFOURL + '/' + params2.userId, params);
}

/**
 * 登出
 */
export function logout() {
    return request.Post(LOGIN_OUT, {});
}

/**
 * 刷新token
 */
export function refreshToken() {
    return request.Post<LoginModel>(REFRESH_TOKEN, {});
}
